package AIRProject.filemanager
{
	import flash.events.Event;
	import flash.events.FileListEvent;
	import flash.events.IEventDispatcher;
	import flash.filesystem.File;
	/**
	 * ...
	 * @author FireKnight
	 */
	public class GetDirectory
	{
		public var func:Function;
		public var path:String;
		
		public function GetDirectory(file:File, path:String, func:Function)
		{
			this.path = path;
			this.func = func;
			if (func != null)
			{
				file.addEventListener(FileListEvent.DIRECTORY_LISTING, directoryListingHandler);
				file.getDirectoryListingAsync();
			}
		}
		
		private function directoryListingHandler(event:FileListEvent):void
		{
			IEventDispatcher(event.currentTarget).removeEventListener(FileListEvent.DIRECTORY_LISTING, directoryListingHandler);
			if (func != null)
			{
				func(path, event.files);
			}
		}
	
	}

}